
#include "ListNode.h"
#include "DeNode.h"
#include <iostream>

template<class Type>
void print(Type* node){
	std::cout<<node->data<<std::endl;
}

typedef Node<int> IntNode;
typedef DeNode<int> IntDeNode;

void DoubleList();
void TestForwardList(){
	//IntNode h = {8,0},
	//	g = {744,&h},	
	//	f= {66,&g},
	//	e= {56,&f},
	//	d= {54,&e},
	//	c = {3,&d},
	//	b= {112,&c},	
	//    a = {651,&b};
	//   IntNode list = {8,&a};

	//   Traverse(&list,&print);

	//   //Reverse(&list);

	//  // InsertionSort(&list);

	//   SelectionSort(&list);
	//   std::cout<<"-----------------------"<<std::endl;

	//   Traverse(&list,&print);

	DoubleList();
}


void DoubleList(){

	IntDeNode h = {8,NULL,NULL},
		g = {744,NULL,&h},	
		f= {66,NULL,&g},
		e= {56,NULL,&f},
		d= {54,NULL,&e},
		c = {3,NULL,&d},
		b= {112,NULL,&c},	
	    a = {651,NULL,&b};
	   IntDeNode list = {-1,&h,&a}; // head

	   a.pre = & list;
	   b.pre = &a;
	   c.pre = &b;
	   d.pre = &c;
	   e.pre = &d;
	   f.pre = &e;
	   g.pre = &f;
	   h.pre = &g;
	   h.next = &list;

	   ForwardTraverse(&list,&print);

	   //Reverse(&list);

	  // InsertionSort(&list);

	  
	   std::cout<<"-----------------------"<<std::endl;

	   BackwardTraverse(&list,&print);

	 

}


